package org.jeecg.modules.jxc.sales_management.salelist_Search.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.lang.StringUtils;
import org.jeecg.modules.jxc.sales_management.salelist_Search.entity.JxcSaleList;
import org.jeecg.modules.jxc.sales_management.salelist_Search.mapper.JxcSaleLisjxcGoodsMapper;
import org.jeecg.modules.jxc.sales_management.salelist_Search.mapper.JxcSaleListMapper;
import org.jeecg.modules.jxc.sales_management.salelist_Search.service.IJxcSaleListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * @Description: jxc_sale_list
 * @Author: jeecg-boot
 * @Date:   2021-12-20
 * @Version: V1.0
 */
@Service
public class JxcSaleListServiceImpl extends ServiceImpl<JxcSaleListMapper, JxcSaleList> implements IJxcSaleListService {

    @Autowired
    private JxcSaleListMapper jxcSaleListMapper;

    @Override
    public IPage<JxcSaleList> getSalelistPage(Page<JxcSaleList> page, String saleDate_begin, String saleDate_end, Integer customerId, Integer state,String saleNumber) {
        QueryWrapper<JxcSaleList> queryWrapper = new QueryWrapper<>();
        if (!StringUtils.isEmpty(saleNumber))
            queryWrapper.like("sale_number",saleNumber);
        if (customerId != null)
            queryWrapper.eq("customer_id",customerId);
        if(state!=null)
            queryWrapper.eq("state",state);
        if(!StringUtils.isEmpty(saleDate_begin))
            queryWrapper.ge("sale_date",saleDate_begin);
        if(!StringUtils.isEmpty(saleDate_end))
            queryWrapper.le("sale_date",saleDate_end);
        Page<JxcSaleList> jxcSaleListPage = jxcSaleListMapper.selectPage(page,queryWrapper);
        return jxcSaleListPage;
    }


}
